package com.axxc.jpa.task.rabbitmsg.provider;

import java.util.Date;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @ClassName: RabbitMqStringMsgProviderTask
 * @Description: StringMsg消息生产者
 * @author xxc
 * @date 2018年8月3日 下午3:27:26
 */
//@Component
public class RabbitMqStringMsgProviderTask {

	@Autowired
	private AmqpTemplate rabbitTemplate;

	@Async
	@Scheduled(cron = "0/10 * * * * *") // 每十秒
	public void reportCurrentTime() {
		for (int i = 0; i < 2; i++) {
			rabbitTemplate.convertAndSend("string_msg_queue", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		}
	}
}
